<template>
<div>
        <van-nav-bar
  title="确认订单"
  left-text="返回"
  left-arrow
  @click-left="()=>{
    $router.back('/')
  }"
/>
<div style="background-color: #ccc;">
 <p>我的订单号：{{ orderdata.orderId }}</p>
<p>订单生成时间：{{ orderdata.create_time }}</p>
<p>订单描述：{{ orderdata.product_code }}</p>
<p>订单价格：{{ orderdata.totalPrice/100 }}</p>   
</div>

<van-submit-bar :price="orderdata.totalPrice" button-text="提交订单" @submit="onSubmit" />

    </div>
</template>

<script setup>
import { ref } from "vue";
import { getOrderApi,payApi } from "@/api/api";
import { useRoute } from "vue-router";
const route=new useRoute()
let orderdata=ref([])
let pay=ref({
    orderId:'',
    subject:'',
    totalPrice:0
})
getOrderApi(route.params.orderId).then(res=>{
    console.log('order',res);
    orderdata.value=res.data.data
    pay.value={
       orderId:res.data.data.orderId ,
       subject:res.data.data.product_code,
       totalPrice:(res.data.data.totalPrice/100).toFixed(2)
    }
})
const onSubmit=()=>{
    payApi(pay.value).then(res=>{
        console.log('pay',res);
        window.open(res.data.data,'_blank')
    })
}
</script>

<style lang="scss" scoped>

</style>